From 12be5ccbb72b41edb990d7487406f19cfa731434 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Wed, 17 Jan 2018 12:36:37 +0100 Subject: [PATCH] label: Update layout width directly form allocation For the one update_layout_width call in size_allocate, we can just use the passed-in allocation width instead of a separate (relatively slow) gtk_widget_get_width call. --- gtk/gtklabel.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 8df6e8f018..cd969492f6 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -3304,19 +3304,6 @@ gtk_label_get_measuring_layout (GtkLabel * label, return copy; } -static void -gtk_label_update_layout_width (GtkLabel *label) -{ - GtkLabelPrivate *priv = gtk_label_get_instance_private (label); - - g_assert (priv->layout); - - if (priv->ellipsize || priv->wrap) - pango_layout_set_width (priv->layout, gtk_widget_get_width (GTK_WIDGET (label)) * PANGO_SCALE); - else - pango_layout_set_width (priv->layout, -1); -} - static void gtk_label_update_layout_attributes (GtkLabel *label) { @@ -3424,7 +3411,8 @@ gtk_label_ensure_layout (GtkLabel *label) if (priv->lines > 0) pango_layout_set_height (priv->layout, - priv->lines); - gtk_label_update_layout_width (label); + if (priv->ellipsize || priv->wrap) + pango_layout_set_width (priv->layout, gtk_widget_get_width (GTK_WIDGET (label)) * PANGO_SCALE); } } @@ -3736,7 +3724,13 @@ gtk_label_size_allocate (GtkWidget *widget, GtkLabelPrivate *priv = gtk_label_get_instance_private (label); if (priv->layout) - gtk_label_update_layout_width (label); + { + if (priv->ellipsize || priv->wrap) + pango_layout_set_width (priv->layout, + allocation->width * PANGO_SCALE); + else + pango_layout_set_width (priv->layout, -1); + } gtk_label_get_ink_rect (label, out_clip); } -- 2.30.2